Skip to content

WIP: map_identity: suggest making the variable mutable when necessary #15268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ada4a
Copy link
Contributor

@ada4a ada4a commented Jul 13, 2025

While working on #15229, I noticed a test case in map_identity which avoids linting in the case where removing the .map() would require the iterator variable to be made mutable. But then I saw #14140, and thought I'd try to adapt its approach, by suggesting both removing the .map() and making the variable mutable.

This is WIP only because I'm not sure about the very last diag.span_note -- I think having a method chained immediately after the .map() is the only case which requires adding mut, so it should be safe to say that method_requiring_mut is always Some. I'd like to do a lintcheck run to see if that's actually true.

@samueltardieu do you think this is a good approach? Maybe there are more lints where we could lint + suggest making the variable mut, instead of not linting?

changelog:map_identity: suggest making the variable mutable when necessary

@rustbot
Copy link
Collaborator

rustbot commented Jul 13, 2025

r? @y21

rustbot has assigned @y21.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 13, 2025
@ada4a ada4a force-pushed the map-identity-sugg-on-mut branch from cb16cf2 to 4ae3029 Compare July 13, 2025 18:22
@ada4a ada4a marked this pull request as draft July 13, 2025 20:53
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 13, 2025
@ada4a ada4a changed the title WIP: map_identity: suggest making the variable mutable when necessary map_identity: suggest making the variable mutable when necessary Jul 13, 2025
@ada4a ada4a changed the title map_identity: suggest making the variable mutable when necessary WIP: map_identity: suggest making the variable mutable when necessary Jul 13, 2025
@ada4a ada4a marked this pull request as ready for review July 13, 2025 20:54
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants